package com.buydeem.springimport;

import com.buydeem.package2.Person;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

/**
 *
 *
 * @author zengchao
 * @date 2022-03-07 10:41:41
 */
public class App {

    public static void main(String[] args) {
        ApplicationContext context = new AnnotationConfigApplicationContext(GlobalConfig.class);
        //获取com.buydeem.springimport.UserService实例
        System.out.println(context.getBean(UserService.class));
        //获取com.buydeem.package2.Person实例
        System.out.println(context.getBean(Person.class));

    }
}

@ComponentScan
@Configuration
@Import(Person.class)
class GlobalConfig{

}
